


def RunLengthEncode(arr):
    
    
    ret=[]
    cnt = 0
    for i in range(len(arr)):
        if cnt == 15: 
            ret.append([15,0])
            cnt = 0
        if arr[i] == 0:
            cnt += 1
            continue
        
        ret.append([cnt, arr[i]])
        cnt = 0
    
    ret.append([cnt,0])
    
    return ret
    
    
if __name__ == "__main__":
    arr=[-30, 2, -5, 0, -2, 1, -2, 0,
    0,  1,  0, 0,  0, 1,  0, 0, 
    0, 1, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0,0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
    
    parr = RunLengthEncode(arr)
    print(parr)
    
    
    